<#include "header.ftl">

<#-- 商品发布页  -->
<script type="text/javascript" src="../../resources/js/public.js"></script>

<div class="g-doc" ng-controller="publicCtrl">
    <div class="m-tab m-tab-fw m-tab-simple f-cb">
        <h2>内容发布</h2>
    </div>
    <div class="n-public">
        <form class="m-form m-form-ht" id="publicForm" name="myForm" novalidate>
            <div class="fmitem">
                <label class="fmlab">标题：</label>
                <div class="fmipt">
                    <input class="u-ipt ipt" name="title" ng-model="name" ng-minlength="2" ng-maxlength="80" placeholder="2-80字符" required/>
                	<span style="color:red" ng-show="myForm.title.$dirty && myForm.title.$invalid">
  					<span ng-show="myForm.title.$dirty && myForm.title.$invalid">长度2-80字符！</span>
  					<span ng-show="myForm.title.$error.required">标题不能为空。</span>
  					</span>
  					
  
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">摘要：</label>
                <div class="fmipt">
                    <input class="u-ipt ipt"  name="summary" ng-model="summary" placeholder="2-140字符" ng-minlength="2" ng-maxlength="140" required/> 
                	<span style="color:red" ng-show="myForm.summary.$dirty && myForm.summary.$invalid">
  					<span ng-show="myForm.summary.$dirty && myForm.summary.$invalid">长度2-140字符！</span>
  					<span ng-show="myForm.summary.$error.required">摘要不能为空。</span>
  					</span>
                
                </div>
            </div>
            <div class="fmitem">
            <label class="fmlab">图片：</label>
            	<div class="fmipt" id="uploadType">
	                <input ng-model="pic" type="radio" value="url"  /> 图片地址
					<input ng-model="pic" type="radio" value="file" /> 本地上传
				</div>	
            </div>
            
             <div class="fmitem">
                <label class="fmlab"></label>
                <div class="fmipt" ng-if="pic=='url'">
                    <input class="u-ipt ipt" name="imageurl" onchange="angular.element(this).scope().showPic(this)" ng-model="image" placeholder="图片地址" required/>
                    <span style="color:red" ng-show="myForm.imageurl.$dirty && myForm.imageurl.$invalid">
  					<span ng-show="myForm.imageurl.$error.required">图片不能为空。</span>
  					</span>
                </div>
                <div class="fmipt" ng-if="pic=='file'">
				 	<input type="file" onchange="angular.element(this).scope().fileChanged(this)" name="uploadfile" id="uploadfile" required/>   				 
   				 <button class="u-btn u-btn-primary"  ng-click="doUpload()">上传</button>
                	<span style="color:red" ng-show="myForm.uploadfile.$dirty && myForm.uploadfile.$invalid">
  					<span ng-show="myForm.uploadfile.$error.required">图片不能为空。</span></span>
                
                </div>
            </div>
          <div class="fmitem">
                <label class="fmlab">正文：</label>
                <div class="fmipt">
                    <textarea class="u-ipt" name="zhengwen" ng-model="description" rows="10" placeholder="2-1000个字符" ng-minlength="2" ng-maxlength="1000" required></textarea> 
                    <span style="color:red" ng-show="myForm.zhengwen.$dirty && myForm.zhengwen.$invalid">
  					<span ng-show="myForm.zhengwen.$dirty && myForm.zhengwen.$invalid">长度2-1000字符！</span>
  					<span ng-show="myForm.zhengwen.$error.required">正文不能为空。</span>
  					</span>
                </div>
            </div>
            <div class="fmitem">
                <label class="fmlab">价格：</label>
                <div class="fmipt">
                    <input class="u-ipt price" type="number" step="0.01" name="price" ng-model="price" required/>元
                    <span style="color:red" ng-show="myForm.price.$dirty && myForm.price.$invalid">
  					<span ng-show="myForm.price.$error.required">价格不能为空。</span>
  					</span>
                </div>
            </div>
            <div class="fmitem fmitem-nolab fmitem-btn">
                <div class="fmipt">
                    <button type="button"  class="u-btn u-btn-primary u-btn-lg" ng-disabled= "userOfLoger==null||description==null||description==''||price==null||price==''||summary==null||summary==''||name==null||name==''||myForm.$pristine ||pic=='file'&& myForm.uploadfile.$dirty && myForm.uploadfile.$invalid || pic=='url'&&myForm.imageurl.$dirty && myForm.imageurl.$invalid ||
                     myForm.title.$dirty && myForm.title.$invalid || myForm.summary.$dirty && myForm.summary.$invalid || myForm.zhengwen.$dirty && myForm.zhengwen.$invalid|| myForm.price.$dirty && myForm.price.$invalid"
                        ng-click="addComm()" >发 布</button>
                </div>
            </div>  </form>
            
        <span class="imgpre" ng-if="pic=='url'"><img ng-src="{{image}}" alt=""></span>
        
        <span class="imgpre" ng-if="pic=='file'"><img ng-src="{{fileName}}" alt=""></span>
      
    </div>
</div>

<#include "footer.ftl">